﻿using System;
/*
 * Write a program that reads the coefficients a, b and c of a 
 * quadratic equation ax2+bx+c=0 and solves it (prints its real roots).
 */

class SolveQuadraticEquasion
{
    static void Main(string[] args)
    {
        Console.WriteLine("Solving a quadratic equasion: a*x*x + b*x + c = 0");
        Console.WriteLine("Enter the coefficient a:");
        double a = Convert.ToDouble(Console.ReadLine());
        Console.WriteLine("Enter the coefficient b:");
        double b = Convert.ToDouble(Console.ReadLine());
        Console.WriteLine("Enter the coefficient c:");
        double c = Convert.ToDouble(Console.ReadLine());

        double determinant = b * b - 4 * a * c;
        if (determinant < 0)
        {
            Console.WriteLine("The quadratic equasion {0}*x*x + {1}*x + {2} has no real roots.", a,b,c);
        }
        else
        { 
            if (determinant == 0)
            {
                Console.WriteLine("The quadratic equasion {0}*x*x + {1}*x + {2} has a single real root:");
                Console.WriteLine("X1/2 : {0}", -b / (2 * a));
            }
            else
            {
                Console.WriteLine("The quadratic equasion {0}*x*x + {1}*x + {2} has 2 real roots:");
                Console.WriteLine("X1 : {0}", (-1 * b - Math.Sqrt(determinant)) / (2 * a));
                Console.WriteLine("X2 : {0}", (-1 * b + Math.Sqrt(determinant)) / (2 * a));
            }
        }

    }
}
